<template>
	<view>
		<uni-nav-bar title="交易记录" color="#fff" background-color="#FD212C" leftIcon="back" @clickLeft="$tab.back()"
			:border="false" :statusBar="true" :fixed="true"></uni-nav-bar>

		<view class="px-32 bg-FFF py-32 mt-32">
			<view class="text-28 font-700">
				当日团队交易{{ statistics }}手
			</view>

			<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :fixed="false">
				<view class="text-28" v-for="(item,index) in list" :key="index" v-if="list.length != 0">
					<u-line color="#EDEDED"></u-line>
					<view class="py-36">
						<view class="flex items-center justify-between mt-32">
							<view class="flex items-center">
								<view class="ml-16" v-if="item.isType==0">
									鹿贝+转化鹿票
									<text class="text-gray text-24">(手续费{{item.serviceAmount||0}}{{item.isType==0?'鹿贝':item.isType==1?'可交易鹿票':''}})</text>
								</view>
								<view class="ml-16" v-if="item.isType==1">
									可交易鹿票
									<text class="text-gray text-24">(手续费{{item.serviceAmount||0}}鹿贝)</text>
								</view>
							</view>
							<view class="text-FF8400" v-if="item.isType==0">
								{{item.lubeiAmount||0}}+{{item.lupiaoAmount||0}}
							</view>
							<view class="text-FF8400" v-if="item.isType==1">
								{{item.zhuanhuaLupiaoAmount ||0}}
							</view>
						</view>
						<view class="color-999 flex items-center justify-between mt-32">
							<view class="flex items-center">
								<view class="ml-16">
									{{item.createTime}}
								</view>
							</view>
							<view>
								交易数({{item.number}}手)
							</view>
						</view>
					</view>
				</view>
			</s-pull-scroll>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				statistics: 0,
			};
		},
		onLoad() {
			this.refresh()
		},
		onShow() {
			this.$Api.user.recordsTeamNum().then((res) => {
				this.statistics = res.data
			})
		},
		methods: {
			refresh() {
				this.$nextTick(() => {
					this.$refs.pullScroll.refresh();
				});
			},
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			loadData(pullScroll) {
				setTimeout(() => {
					this.$Api.user.recordsList({
						pageNum: pullScroll.page,
						pageSize: 10,
					}).then(res => {
						if (pullScroll.page == 1) {
							this.list = [];
						}
						this.list = this.list.concat(res.rows || []);
						if (pullScroll.page == 1 && res.total == 0) {
							pullScroll.empty();
							return
						}
						if (this.list.length >= res.total) {
							pullScroll.finish();
						} else {
							pullScroll.success();
						}
					})
				}, 500);
			},
		}
	}
</script>

<style lang="scss">

</style>
